import java.util.Comparator;
import java.util.PriorityQueue;

class Solution {
    public int[] kthSmallestPrimeFraction(int[] arr, int k) {
        PriorityQueue<int[]> maxHeap=new PriorityQueue<>();
        int len=arr.length;
        for(int i=0;i<len;i++){
            for(int j=i+1;j<len;j++){
                int[] cur=new int[]{arr[i],arr[j]};
                if(maxHeap.size()<k){
                    maxHeap.offer(cur);
                }else{
                    if(isSmaller(cur,maxHeap.peek())){//如果下一个小于堆顶元素则，将堆顶元素与其替换，因为要保证外面的元素比堆里的元素大，这样堆顶元素就是第k小的元素
                        maxHeap.poll();
                        maxHeap.offer(cur);
                    }
                }
            }
        }
        return maxHeap.peek();
    }
    public boolean isSmaller(int[] cur,int[] pre){
        return cur[0]*pre[1]-cur[1]*pre[0]<0;
    }

    public static void main(String[] args) {
        String s="1,2,3,4,";
        String[] data=s.split(",");
        for (String tmp:data) {
            System.out.println(tmp);
         }
    }
}

class Intcmp implements Comparator<int[]> {

    @Override
    public int compare(int[] o1, int[] o2) {
        return o2[0]*o1[1]-o1[0]*o2[1];
    }
}
